<title>Rake</title>

<% unless @datasource.default? %>
  <%#= link_to raw("&larr; Back"), rails_performance_path, class: "back_link" %>
<% end %>

<div class="card">
  <div class="card-content">
    <h2 class="subtitle">Recent Rake tasks (last <%= RailsPerformance.recent_requests_time_window / 60 %> minutes)<h2>

    <table class="table is-fullwidth is-hoverable is-narrow">
      <thead>
        <tr>
          <th data-sort="string">Datetime</th>
          <th data-sort="string">Details</th>
          <th data-sort="float">Duration</th>
          <th data-sort="string">Status</th>
        </tr>
      </thead>
      <tbody>
        <% if @recent_report_data.empty? %>
          <tr>
            <td colspan="10">Nothing to show here. Try to make a few requests in the main app.</td>
          </tr>
        <% end %>
        <% @recent_report_data.each do |e| %>
          <tr>
            <td><%= format_datetime e[:datetime] %></td>
            <td>[<%= e[:task].join(" ") %>]</td>
            <td class="nowrap"><%= ms e[:duration] %></td>
            <td><%= status_tag e[:status] %></td>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>
</div>

<br/>

<div class="card">
  <div class="card-content">
    <h2 class="subtitle">Rake Throughput Report</h2>
    <div id="throughput_report_chart" class="chart"></div>
    <p class="content is-small">All rake tasks in the application</p>
  </div>
</div>


<% content_for :on_load do %>
  <script>
    var data1 = <%= raw @throughput_report_data.to_json %>;
    showTIRChart('throughput_report_chart', data1, ' tasks / minute', 'Tasks');
  </script>
<% end %>
